package com.todolist.server.persistence;

import com.todolist.shared.domain.Project;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProjectMapper {

    @Select("SELECT * FROM projects WHERE name = #{name}")
    Project getProject(@Param("name") String name);

    @Select("INSERT INTO projects (name) VALUES (#{name})")
    void addProject(@Param("name") String name);

    @Select("UPDATE projects SET name = #{newName} WHERE name = #{oldName}")
    void updateProjectName(@Param("oldName") String oldName, @Param("newName") String newName);

    @Select("DELETE FROM projects WHERE name = #{name}")
    void deleteProject(@Param("name") String name);

    @Select("SELECT * FROM projects")
    List<Project> getProjects();
}
